package com.jic.market.common.util;

import java.io.InputStream;
import java.security.MessageDigest;

public class MD5Utils {
    private static char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};

    public MD5Utils() {
    }

    public static String md5(Object... params) {
        if (params != null && params.length > 0) {
            StringBuffer sb = new StringBuffer();
            Object[] var2 = params;
            int var3 = params.length;

            for(int var4 = 0; var4 < var3; ++var4) {
                Object o = var2[var4];
                sb.append(o.toString());
            }

            return md5(sb.toString());
        } else {
            throw new RuntimeException("...");
        }
    }

    public static String md5(InputStream is) {
        String ret = null;

        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.reset();
            byte[] dataBytes = new byte[1024];
            boolean var4 = false;

            int nread;
            while((nread = is.read(dataBytes)) != -1) {
                md.update(dataBytes, 0, nread);
            }

            byte[] mdbytes = md.digest();
            ret = md5byte2Str(mdbytes);
        } catch (Exception var6) {
            var6.printStackTrace();
        }

        return ret;
    }

    public static String md5(String str) {
        Object ret = null;

        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] bs = str.getBytes("UTF-8");
            md.reset();
            md.update(bs);
            byte[] md5bytes = md.digest();
            return md5byte2Str(md5bytes);
        } catch (Exception var5) {
            var5.printStackTrace();
            return (String)ret;
        }
    }

    public static String md5(byte[] bytes) {
        Object ret = null;

        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.reset();
            md.update(bytes);
            byte[] md5bytes = md.digest();
            return md5byte2Str(md5bytes);
        } catch (Exception var4) {
            var4.printStackTrace();
            return (String)ret;
        }
    }

    public static String md5byte2Str(byte[] md5bytes) {
        char[] md5chars = new char[32];
        int k = 0;
        byte[] var3 = md5bytes;
        int var4 = md5bytes.length;

        for(int var5 = 0; var5 < var4; ++var5) {
            byte b = var3[var5];
            md5chars[k++] = hexDigits[b >>> 4 & 15];
            md5chars[k++] = hexDigits[b & 15];
        }

        return new String(md5chars);
    }

    public static void main(String[] args) {
        String ss = "100299561,1000391262,1000347757,100297709,1000010231,1104260399,1000010089,1116670290,1116620016,1110620161,1112530032,1000039426,9128930967,100293707,100285150,1000369438,1000353340,1000392524,1000376686,1000341380,1118220181,1115410200,1118220133,1107660210,1115900229,1116120051,1105420249,1118220176,1000167156,1000265702,1000362966,1000386144,1105620056,1118100333,1000057889,1181991015,1111030060,1000028561,1112830082,1116790103";
        String[] sa = ss.split(",");
        String[] var3 = sa;
        int var4 = sa.length;

        for(int var5 = 0; var5 < var4; ++var5) {
            String s = var3[var5];
            System.out.println(md5(s));
        }

    }
}
